<!DOCTYPE html>
<html>
<head>
<title>添加模型</title>
#include("../include/common.html")
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>添加模型</h5>
            </div>
           <form id="inputForm" action="save" method="post">
	            <div class="ibox-content">
	                <div class="form-horizontal clearfix">
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label">名称：</label>
	                        <div class="col-sm-3">
	                            <input class="form-control" type="text" name="name">
	                        </div>
	                    </div>
	                    <div class="form-group">
                            <label class="col-sm-3 control-label">类型：</label>
                            <div class="col-sm-3">
                                <div class="radio" id="type">
                                    <label class="m-r"><input name="type" value="1" type="radio">栏目</label>
                                    <label class="m-r"><input name="type" value="2" type="radio">表单</label>
                                    <label class="m-r"><input name="type" value="3" type="radio">自定义表</label>
                                </div>
                            </div>
                        </div>
	                    <div class="form-horizontal clearfix" id="type1" style="display: none">
		                    <div class="form-group">
		                        <label class="col-sm-3 control-label">列表模板：</label>
		                        <div class="col-sm-3">
		                            <input class="form-control" type="text" name="listTemplate">
		                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>例如：news_list.html。不填写则会是:模型名称拼音小写_list.html</span>
		                        </div>
		                    </div>
		                    <div class="form-group">
		                        <label class="col-sm-3 control-label">内容模板：</label>
		                        <div class="col-sm-3">
		                            <input class="form-control" type="text" name="contentTemplate">
		                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>例如：news_detail.html。不填写则会是:模型名称拼音小写_detail.html</span>
		                        </div>
		                    </div>
	                    </div>
                        <div class="form-horizontal clearfix" id="type2" style="display: none">
	                        <div class="form-group">
	                            <label class="col-sm-3 control-label">是否需要验证码：</label>
	                            <div class="col-sm-3">
	                                <div class="radio">
	                                    <label class="m-r"><input name="isCaptcha" value="true" type="radio">是</label>
	                                    <label class="m-r"><input name="isCaptcha" value="false" type="radio">否</label>
	                                </div>
	                            </div>
	                        </div>
	                    </div>
	                    <div class="form-horizontal clearfix" id="type3" style="display: none">
	                       <div class="form-group">
                                <label class="col-sm-3 control-label">数据库表：</label>
                                <div class="col-sm-3">
                                    <input class="form-control" type="text" name="tableName" id="tableName">
                                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>例如：cms_self_user。</span>
                                </div>
                            </div>
	                    </div>
	                </div>
	            </div>
	            <div class="modal-footer col-sm-3 col-sm-offset-2">
	                <button type="submit" class="btn btn-w-m btn-primary">确定</button>
	                <button type="button" class="btn btn-w-m btn-default" onclick="history.back(); return false;">取消</button>
	            </div>
            </form>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
$().ready(function() {

	var $inputForm = $("#inputForm");
	var $type = $("#type");
	var $isCaptcha = $("input[name='isCaptcha']");
	var $tableName = $("#tableName");
	
	$type.on("click","input[type='radio']",function(){
		$("#type1").hide();
        $("#type2").hide();
        $("#type3").hide();
        if("2"==$(this).val()){
        	$isCaptcha.rules("add",{required:true});
        	$tableName.rules("remove");
        }else if("3"==$(this).val()){
        	$tableName.rules("add",{required:true});
        	$isCaptcha.rules("remove");
        }else{
        	$tableName.rules("remove");
        	$isCaptcha.rules("remove");
        }
        $("#type"+$(this).val()).show();
    });
	
	// 表单验证
	$inputForm.validate({
		rules: {
			name: "required",
			type: "required"
		}
	});

});
</script>